Skip to content

fix(network-activity-plugin): remove private react-native WebSocketInterceptor import - #398

Merged
V3RON merged 2 commits into
mainfrom
fix/network-activity-plugin-websocket-interceptor-private-api
Aug 13, 2026
Merged

fix(network-activity-plugin): remove private react-native WebSocketInterceptor import#398
V3RON merged 2 commits into
mainfrom
fix/network-activity-plugin-websocket-interceptor-private-api

Conversation

@V3RON

@V3RON V3RON commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

@rozenite/network-activity-plugin imported React Native's private react-native/Libraries/WebSocket/WebSocketInterceptor module to power the network inspector's WebSocket tab. This deep import path resolves to null under React Native's Strict TypeScript API, which breaks module resolution for apps that opt into it.

This PR vendors the interceptor logic locally instead, rebuilt entirely on React Native's public API surface, so the package no longer depends on any private React Native module path.

Related Issue

Closes #396

Context

  • Added native-websocket-module.ts, which looks up the native WebSocket module via the public TurboModuleRegistry.getEnforcing('WebSocketModule') instead of importing NativeWebSocketModule from Libraries/WebSocket/.
  • Rewrote websocket-interceptor.ts to reimplement the connect/send/sendBinary/close monkey-patching and event subscription logic using the public NativeEventEmitter export, keeping the same WebSocketInterceptor interface so websocket-inspector.ts required no changes.
  • Dropped the RN-0.79 argument-order compatibility shim (WebSocketInterceptorPreRN079) — since this package now owns the callback wiring end-to-end, there's nothing external to compensate for.
  • Removed the now-unused websocket-interceptor-types.d.ts ambient module declaration.
  • Added base64-js (previously only an indirect dependency via react-native) as an explicit dependency for the binary-message display helper.

Testing

  • pnpm --filter @rozenite/network-activity-plugin typecheck
  • pnpm --filter @rozenite/network-activity-plugin lint
  • pnpm --filter @rozenite/network-activity-plugin test — 197 tests passed

V3RON and others added 2 commits August 12, 2026 19:06
…ebSocket interceptor

Vendors the WebSocket interception logic locally instead of importing
react-native/Libraries/WebSocket/WebSocketInterceptor, using the public
TurboModuleRegistry/NativeEventEmitter APIs to look up the native module.
Avoids breakage under React Native's Strict TypeScript API, which blocks
deep imports into Libraries/* and src/private/*.

Claude-Session: https://claude.ai/code/session_01JaNGs52mExzVBMFbjLgWgo
@V3RON
V3RON merged commit bb45bb6 into main Aug 13, 2026
4 checks passed
@V3RON
V3RON deleted the fix/network-activity-plugin-websocket-interceptor-private-api branch August 13, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(network-activity-plugin): remove private react-native/Libraries/WebSocket/WebSocketInterceptor import

1 participant